#编程实现一个元素全为数字的列表，求最大值、最小值
import random

num = [random.randint(1,999),random.randint(1,999),random.randint(1,999),random.randint(1,999),random.randint(1,999),random.randint(1,999),random.randint(1,999),random.randint(1,999),random.randint(1,999),random.randint(1,999)]

num.sort()#从小到大排序
print("该列表中最小值为{}，最大值为{}".format(num[0],num[len(num)-1]))

max=num[0]
min=num[0]
for n in num:
    if n >max:
        max = n
    if n <min:
        min = n
print("最大值",max,"最小值",min)


maxIndex = 0
for p in range(0,len(num)):
    if num[p] > num[maxIndex]:
        maxIndex = p
print("最大值",num[maxIndex])



# 任意输入一串数字，判断当前数字是否是标准手机号，不考虑非数字情况



num = "13245675645"
prefixes = ["13", "14", "15", "16", "17", "18", "19"]

if len(num) != 11:
    print("手机号长度应为11位")
elif not num.isdigit():
    print("手机号应为纯数字组合")
elif num[:2] in prefixes:  # 直接判断前两位是否在prefixes中
    print("该手机号正确")
else:
    print("手机号开头数字不正确")



# phone = "19823232341"
# if len(phone) == 11:
#     if phone.isdigit():
#         if phone.startswith("18") or phone.startswith("19") or phone.startswith("13") or phone.startswith(
#                 "14") or phone.startswith("15") or phone.startswith("16") or phone.startswith("17"):
#             print("手机号格式正确")
#         else:
#             print("手机号格式错误")
#     else:
#         print("手机号应是纯数字组成的")
# else:
#     print("手机号长度应为11位")


